home *** CD-ROM | disk | FTP | other *** search
/ Stone Design / Stone Design.iso / Stone_Friends / Wave / WavesWorld / Source / Libraries / tcl7.4b3 / doc / exec.n < prev    next >
Encoding:
Text File  |  1994-12-17  |  6.6 KB  |  186 lines

  1. '\"
  2. '\" Copyright (c) 1993 The Regents of the University of California.
  3. '\" Copyright (c) 1994 Sun Microsystems, Inc.
  4. '\"
  5. '\" See the file "license.terms" for information on usage and redistribution
  6. '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  7. '\" 
  8. '\" @(#) exec.n 1.7 94/12/17 16:17:49
  9. '\" 
  10. .so man.macros
  11. .HS exec tcl 7.0
  12. .BS
  13. '\" Note:  do not modify the .SH NAME line immediately below!
  14. .SH NAME
  15. exec \- Invoke subprocess(es)
  16. .SH SYNOPSIS
  17. \fBexec \fR?\fIswitches\fR? \fIarg \fR?\fIarg ...\fR?
  18. .BE
  19.  
  20. .SH DESCRIPTION
  21. .PP
  22. This command treats its arguments as the specification
  23. of one or more subprocesses to execute.
  24. The arguments take the form of a standard shell pipeline
  25. where each \fIarg\fR becomes one word of a command, and
  26. each distinct command becomes a subprocess.
  27. .PP
  28. If the initial arguments to \fBexec\fR start with \fB\-\fR then
  29. .VS
  30. they are treated as command-line switches and are not part
  31. of the pipeline specification.  The following switches are
  32. currently supported:
  33. .TP 13
  34. \fB\-keepnewline
  35. Retains a trailing newline in the pipeline's output.
  36. Normally a trailing newline will be deleted.
  37. .TP 13
  38. \fB\-\|\-\fR
  39. Marks the end of switches.  The argument following this one will
  40. be treated as the first \fIarg\fR even if it starts with a \fB\-.
  41. .VE
  42. .PP
  43. If an \fIarg\fR (or pair of \fIarg\fR's) has one of the forms
  44. described below then it is used by \fBexec\fR to control the
  45. flow of input and output among the subprocess(es).
  46. Such arguments will not be passed to the subprocess(es).  In forms
  47. .VS
  48. such as ``< \fIfileName\fR'' \fIfileName\fR may either be in a
  49. separate argument from ``<'' or in the same argument with no
  50. intervening space (i.e. ``<\fIfileName\fR'').
  51. .VE
  52. .TP 15
  53. |\fR
  54. Separates distinct commands in the pipeline.  The standard output
  55. of the preceding command will be piped into the standard input
  56. of the next command.
  57. .TP 15
  58. |&\fR
  59. Separates distinct commands in the pipeline.  Both standard output
  60. and standard error of the preceding command will be piped into
  61. the standard input of the next command.
  62. This form of redirection overrides forms such as 2> and >&.
  63. .TP 15
  64. <\0\fIfileName\fR
  65. The file named by \fIfileName\fR is opened and used as the standard
  66. input for the first command in the pipeline.
  67. .TP 15
  68. <@\0\fIfileId\fR
  69. .VS
  70. \fIFileId\fR must be the identifier for an open file, such as the return
  71. value from a previous call to \fBopen\fR.
  72. It is used as the standard input for the first command in the pipeline.
  73. \fIFileId\fR must have been opened for reading.
  74. .VE
  75. .TP 15
  76. <<\0\fIvalue\fR
  77. \fIValue\fR is passed to the first command as its standard input.
  78. .TP 15
  79. >\0\fIfileName\fR
  80. Standard output from the last command is redirected to the file named
  81. \fIfileName\fR, overwriting its previous contents.
  82. .TP 15
  83. 2>\0\fIfileName\fR
  84. .VS
  85. Standard error from all commands in the pipeline is redirected to the
  86. file named \fIfileName\fR, overwriting its previous contents.
  87. .TP 15
  88. >&\0\fIfileName\fR
  89. Both standard output from the last command and standard error from all
  90. commands are redirected to the file named \fIfileName\fR, overwriting
  91. its previous contents.
  92. .VE
  93. .TP 15
  94. >>\0\fIfileName\fR
  95. Standard output from the last command is
  96. redirected to the file named \fIfileName\fR, appending to it rather
  97. than overwriting it.
  98. .TP 15
  99. 2>>\0\fIfileName\fR
  100. .VS
  101. Standard error from all commands in the pipeline is
  102. redirected to the file named \fIfileName\fR, appending to it rather
  103. than overwriting it.
  104. .TP 15
  105. >>&\0\fIfileName\fR
  106. Both standard output from the last command and standard error from
  107. all commands are redirected to the file named \fIfileName\fR,
  108. appending to it rather than overwriting it.
  109. .TP 15
  110. >@\0\fIfileId\fR
  111. \fIFileId\fR must be the identifier for an open file, such as the return
  112. value from a previous call to \fBopen\fR.
  113. Standard output from the last command is redirected to \fIfileId\fR's
  114. file, which must have been opened for writing.
  115. .TP 15
  116. 2>@\0\fIfileId\fR
  117. \fIFileId\fR must be the identifier for an open file, such as the return
  118. value from a previous call to \fBopen\fR.
  119. Standard error from all commands in the pipeline is
  120. redirected to \fIfileId\fR's file.
  121. The file must have been opened for writing.
  122. .TP 15
  123. >&@\0\fIfileId\fR
  124. \fIFileId\fR must be the identifier for an open file, such as the return
  125. value from a previous call to \fBopen\fR.
  126. Both standard output from the last command and standard error from
  127. all commands are redirected to \fIfileId\fR's file.
  128. The file must have been opened for writing.
  129. .VE
  130. .PP
  131. If standard output has not been redirected then the \fBexec\fR
  132. command returns the standard output from the last command
  133. in the pipeline.
  134. If any of the commands in the pipeline exit abnormally or
  135. are killed or suspended, then \fBexec\fR will return an error
  136. and the error message will include the pipeline's output followed by
  137. error messages describing the abnormal terminations; the
  138. \fBerrorCode\fR variable will contain additional information
  139. about the last abnormal termination encountered.
  140. If any of the commands writes to its standard error file and that
  141. standard error isn't redirected,
  142. then \fBexec\fR will return an error;  the error message
  143. will include the pipeline's standard output, followed by messages
  144. about abnormal terminations (if any), followed by the standard error
  145. output.
  146. .PP
  147. If the last character of the result or error message
  148. is a newline then that character is normally deleted
  149. from the result or error message.
  150. This is consistent with other Tcl return values, which don't
  151. normally end with newlines.
  152. .VS
  153. However, if \fB\-keepnewline\fR is specified then the trailing
  154. newline is retained.
  155. .VE
  156. .PP
  157. If standard input isn't redirected with ``<'' or ``<<''
  158. or ``<@'' then the standard input for the first command in the
  159. pipeline is taken from the application's current standard input.
  160. .PP
  161. If the last \fIarg\fR is ``&'' then the pipeline will be
  162. executed in background.
  163. .VS
  164. In this case the \fBexec\fR command will return a list whose
  165. elements are the process identifiers for all of the subprocesses
  166. in the pipeline.
  167. .VE
  168. The standard output from the last command in the pipeline will
  169. go to the application's standard output if it hasn't been
  170. redirected, and error output from all of
  171. the commands in the pipeline will go to the application's
  172. standard error file unless redirected.
  173. .PP
  174. The first word in each command is taken as the command name;
  175. tilde-substitution is performed on it, and if the result contains
  176. no slashes then the directories
  177. in the PATH environment variable are searched for
  178. an executable by the given name.
  179. If the name contains a slash then it must refer to an executable
  180. reachable from the current directory.
  181. No ``glob'' expansion or other shell-like substitutions
  182. are performed on the arguments to commands.
  183.  
  184. .SH KEYWORDS
  185. execute, pipeline, redirection, subprocess
  186.